// import  "nprogress/nprogress.css";
// import {start,done,configure} from 'nprogress '

import "nprogress/nprogress.css";
import { start, done, configure } from "nprogress";
import NotFound from '../views/NotFound.vue'

configure({
  trickleSpeed:20,
  showSpinner:false
})

window.start = start;
window.done = done;
function delay(durtion){
  return new Promise((resolve)=>{
    setTimeout(() => {
      resolve()
    }, durtion);
  })
}

function getPageComponent(pageCompResolover){
  return async ()=>{
    start();
    if(process.env.NODE_ENV === "development"){
      await delay(2000)
    }
    const comp = await pageCompResolover();
    done();
    return comp;
  }
}

export default [{
    name: "Home",
    path: "/",
    component: getPageComponent(()=>
      import("@/views/Home")
    ),
    meta:{
      title: "首页"
    }
  },
  {
    name: "About",
    path: "/about",
    component: getPageComponent(()=>
    import("@/views/About")
  ),
    // component:  ()=>import("@/views/About"),
    meta:{
      title: "关于我"
    }
  },
  {
    name: "Blog",
    path: "/blog",
    component: getPageComponent(()=>
    import("@/views/Blog")
  ),
    // component: ()=>import("@/views/Blog"),
    meta: {
      title:"文章详情"
    }
  },
  {
    name: "CategoryBlog",
    path: "/article/cate/:categoryId",
    component: getPageComponent(()=>
    import("@/views/Blog")
  ),
    // component:  ()=>import("@/views/Blog")
  },
  {
    name: "BlogDetail",
    path: "/article/:id",
    component: getPageComponent(()=>
    import("@/views/Blog/Detail")
  ),
    // component: ()=>import("@/views/Blog/Detail")
  },
  {
    name: "Project",
    path: "/project",
    component: getPageComponent(()=>
    import("@/views/Project")
  ),
    // component: ()=>import("@/views/Project"),
    meta:{
      title:"项目效果"
    } 
  },
  {
    name: "Message",
    path: "/message",
    component: getPageComponent(()=>
    import("@/views/Message")
  ),
    // component:  ()=>import("@/views/Message"),
    meta:{
      title: "留言板"
    }
  },
  {
    name:"NotFound",
    path:"*",
    component:NotFound
  }
];